/**
 * @Copyright (C) 2019 广州金鹏集团有限公司.
 * 本系统是商用软件,未经授权擅自复制或传播本程序的部分或全部将是非法的.
 * @创建人: 赵力
 * @创建时间: 2019-01-22 14:02
 * @版本: V1.0
 */
package com.ikcai.enginegraph.controller;

import com.ikcai.enginegraph.domain.base.BaseRelationship;
import com.ikcai.enginegraph.domain.node.Person;
import com.ikcai.enginegraph.pojo.vo.PersonRelationshipVO;
import com.ikcai.enginegraph.service.IPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @类功能说明: 人员控制类
 * @创建人: 赵力
 * @创建时间: 2019-01-22 14:02
 */
@RestController
@RequestMapping("/person")
public class PersonController {

    @Autowired
    private IPersonService personService;

    @RequestMapping(path = "/addPerson", method = RequestMethod.POST)
    public Person addPerson(@RequestBody Person person) {
        return personService.addPerson(person);
    }

    @RequestMapping(path = "/getUserNodeList", method = RequestMethod.GET)
    public Person getPerson(@Param("name") String name) {
        return personService.getPersonByName(name);
    }

    @RequestMapping(path = "/deletePerson", method = RequestMethod.POST)
    public boolean deletePerson(@RequestBody Long id) {
        return personService.deletePerson(id);
    }


    @RequestMapping(path = "/addPersonRelationship", method = RequestMethod.POST)
    public BaseRelationship addPersonRelationship(@RequestBody PersonRelationshipVO vo) {
        return personService.addPersonRelationship(vo.getName(),vo.getStartName(),vo.getEndName());
    }

    @RequestMapping(path = "/addPersonWeapon", method = RequestMethod.POST)
    public BaseRelationship addPersonWeapon(@RequestBody PersonRelationshipVO vo) {
        return personService.addPersonWeapon(vo.getName(),vo.getStartName(),vo.getEndName());
    }

    @RequestMapping(path = "/getPersonRelationship", method = RequestMethod.POST)
    public BaseRelationship getPersonRelationship(@RequestBody PersonRelationshipVO vo) {
        return personService.getPersonRelationship(vo.getName(),vo.getStartName(),vo.getEndName());
    }
}
